home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Form & Validation / double-enter-form-field.izs < prev    next >
Text File  |  2005-08-29  |  2KB  |  94 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Double-enter form field script
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>You've probably encountered forms where you're asked to double-enter a field, such as the email or password field. This provides confirmation on the accuracy of the input.
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>form and form validation<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <script>
  14.  
  15. var fieldalias="Email address field"
  16.  
  17. function verify(element1, element2){
  18. var passed=false
  19. if (element1.value==''){
  20. alert("Please fill out the "+fieldalias+"!")
  21. element1.focus()
  22. }
  23. else if (element2.value==''){
  24. alert("Please verify the "+fieldalias+"!")
  25. element2.focus()
  26. }
  27. else if (element1.value!=element2.value){
  28. alert("The two "+fieldalias+"s do not match")
  29. element1.select()
  30. }
  31. else
  32. passed=true
  33.  
  34. return passed
  35.  
  36. }
  37.  
  38. </script>
  39. <!--Replace "emailone" and "emailtwo" with name of the two associated fields-->
  40. <form name=test onSubmit="return verify(this.emailone, this.emailtwo)">
  41.  
  42. Enter email: <input type="text" name="emailone"><br>
  43. Re-Enter email:<input type="text" name="emailtwo"><br>
  44.  
  45. <input type="submit" value="submit">
  46. </form>
  47. <!-- END OF SCRIPT -->
  48. <!/SCRIPT>
  49.  
  50. <!PREVIEW>
  51. <!-- START OF SCRIPT -->
  52. <script>
  53.  
  54. //Double-enter form element script- by Jon Caws joncaws@btinternet.com
  55. //Visit JavaScript Kit (http://www.javascriptkit.com) for script
  56. //Credit must stay intact for use
  57.  
  58. var fieldalias="Email address field"
  59.  
  60. function verify(element1, element2){
  61. var passed=false
  62. if (element1.value==''){
  63. alert("Please fill out the "+fieldalias+"!")
  64. element1.focus()
  65. }
  66. else if (element2.value==''){
  67. alert("Please verify the "+fieldalias+"!")
  68. element2.focus()
  69. }
  70. else if (element1.value!=element2.value){
  71. alert("The two "+fieldalias+"s do not match")
  72. element1.select()
  73. }
  74. else
  75. passed=true
  76.  
  77. return passed
  78.  
  79. }
  80.  
  81. </script>
  82. <!--Replace "emailone" and "emailtwo" with name of the two associated fields-->
  83. <form name=test onSubmit="return verify(this.emailone, this.emailtwo)">
  84.  
  85. Enter email: <input type="text" name="emailone"><br>
  86. Re-Enter email:<input type="text" name="emailtwo"><br>
  87.  
  88. <input type="submit" value="submit">
  89. </form>
  90.  
  91. <!-- END OF SCRIPT -->
  92. <!/PREVIEW>
  93.  
  94. <!RELATED>NONE<!/RELATED>